package model
{
	import bean.HistoryLog;

	import mx.collections.ArrayCollection;


	[Bindable]
	public class AppModelLocator
	{
		//----------------------------------------------------------------------
		//
		//	Constant
		//
		//----------------------------------------------------------------------

		public static const PLEASE_CHOICE:String="请选择";

		public static const NO_CHOICE:String="-1";
		public static const CHOICE_ONE:String="1";
		public static const CHOICE_TWO:String="2";
		public static const CHOICE_THREE:String="3";
		public static const CHOICE_FOUR:String="4";

		public static const dayNames:Array=['日', '一', '二', '三', '四', '五', '六'];
		public static const monthNames:Array=['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];

		//----------------------------------------------------------------------
		//
		//	Variables
		//
		//----------------------------------------------------------------------

		public var queryTypeAC:ArrayCollection=new ArrayCollection();
		public var operationTypeAC:ArrayCollection=new ArrayCollection();
		public var operationTypeAC1:ArrayCollection=new ArrayCollection();
		public var operationTypeAC2:ArrayCollection=new ArrayCollection();
		public var operationTypeAC3:ArrayCollection=new ArrayCollection();
		public var operationTypeAC4:ArrayCollection=new ArrayCollection();
		public var operationTypeAC5:ArrayCollection=new ArrayCollection();
		public var operationUnitAC:ArrayCollection=new ArrayCollection();
		public var operationProtocolAC:ArrayCollection=new ArrayCollection();
		public var operationActionAC:ArrayCollection=new ArrayCollection();
		public var sortAC:ArrayCollection=new ArrayCollection();

		/**
		 * This returns and instance of the custom AppModelLocator.
		 * @return AppModelLocator
		 */
		public static function getInstance():model.AppModelLocator
		{

			if (__AppModelLocator == null)
			{
				__AppModelLocator=new model.AppModelLocator(new ConstructorBlock);
			}

			return __AppModelLocator;
		}

		/**
		 * Default constructor.
		 * @param block Private class required.
		 *              Prevents public, direct instantiation of multiple instances
		 */
		public function AppModelLocator(block:ConstructorBlock)
		{
			if (model.AppModelLocator.__AppModelLocator != null)
			{
				throw new Error("Only one AppModelLocator instance should be instantiated");
			}
			model.AppModelLocator.__AppModelLocator=this;
			initAC();
		}

		private function initAC():void
		{
			queryTypeAC.addItem({name: PLEASE_CHOICE, value: NO_CHOICE, operation: NO_CHOICE});
			queryTypeAC.addItem({name: 'Lease Issue', value: HistoryLog.Query_field_lease_issue, operation: CHOICE_ONE});
			queryTypeAC.addItem({name: 'Protocol', value: HistoryLog.Query_field_protocol, operation: CHOICE_THREE});
			queryTypeAC.addItem({name: 'IP Address', value: HistoryLog.Query_field_ip_address, operation: CHOICE_FOUR});
			queryTypeAC.addItem({name: 'MAC Address', value: HistoryLog.Query_field_mac_address, operation: CHOICE_FOUR});
			queryTypeAC.addItem({name: 'DUID', value: HistoryLog.Query_field_duid, operation: CHOICE_FOUR});
			queryTypeAC.addItem({name: 'Host Name', value: HistoryLog.Query_field_host_name, operation: CHOICE_FOUR});
			queryTypeAC.addItem({name: 'Action', value: HistoryLog.Query_field_action, operation: CHOICE_THREE});
			queryTypeAC.addItem({name: 'User Name', value: HistoryLog.Query_field_user_name, operation: CHOICE_FOUR});
			queryTypeAC.addItem({name: 'Start', value: HistoryLog.Query_field_start, operation: CHOICE_ONE});
			queryTypeAC.addItem({name: 'Stop', value: HistoryLog.Query_field_stop, operation: CHOICE_TWO});
//			queryTypeAC.addItem({name: 'Member Host Name', value: HistoryLog.Query_field_member_host_name, operation: CHOICE_FOUR});
			queryTypeAC.addItem({name: 'Member IP Address', value: HistoryLog.Query_field_member_ip_address, operation: CHOICE_FOUR});

			operationTypeAC.addItem({name: PLEASE_CHOICE, value: NO_CHOICE});

			operationTypeAC1.addItem({name: PLEASE_CHOICE, value: NO_CHOICE});
			operationTypeAC1.addItem({name: 'on', value: HistoryLog.Date_op_on});
			operationTypeAC1.addItem({name: 'before', value: HistoryLog.Date_op_before});
			operationTypeAC1.addItem({name: 'after', value: HistoryLog.Date_op_after});
			operationTypeAC1.addItem({name: 'within the last', value: HistoryLog.Date_op_withinLast});
			operationTypeAC1.addItem({name: 'today', value: HistoryLog.Date_op_today});
			operationTypeAC1.addItem({name: 'yesterday', value: HistoryLog.Date_op_yesterday});
			operationTypeAC1.addItem({name: 'this week', value: HistoryLog.Date_op_thisWeek});
			operationTypeAC1.addItem({name: 'this month', value: HistoryLog.Date_op_thisMonth});
			operationTypeAC1.addItem({name: 'between', value: HistoryLog.Date_op_between});

			operationTypeAC2.addItem({name: PLEASE_CHOICE, value: NO_CHOICE});
			operationTypeAC2.addItem({name: 'on', value: HistoryLog.Date_op_on});
			operationTypeAC2.addItem({name: 'before', value: HistoryLog.Date_op_before});
			operationTypeAC2.addItem({name: 'after', value: HistoryLog.Date_op_after});
			operationTypeAC2.addItem({name: 'within the last', value: HistoryLog.Date_op_withinLast});
			operationTypeAC2.addItem({name: 'today', value: HistoryLog.Date_op_today});
			operationTypeAC2.addItem({name: 'yesterday', value: HistoryLog.Date_op_yesterday});
			operationTypeAC2.addItem({name: 'this week', value: HistoryLog.Date_op_thisWeek});
			operationTypeAC2.addItem({name: 'this month', value: HistoryLog.Date_op_thisMonth});
			operationTypeAC2.addItem({name: 'never', value: HistoryLog.Date_op_never});
			operationTypeAC2.addItem({name: 'between', value: HistoryLog.Date_op_between});

			operationTypeAC3.addItem({name: PLEASE_CHOICE, value: NO_CHOICE});
			operationTypeAC3.addItem({name: 'equals', value: HistoryLog.String_op_equals_choice, type: HistoryLog.Query_field_protocol});

			operationTypeAC4.addItem({name: PLEASE_CHOICE, value: NO_CHOICE});
			operationTypeAC4.addItem({name: 'equals', value: HistoryLog.String_op_equals_choice, type: HistoryLog.Query_field_action});

			operationTypeAC5.addItem({name: PLEASE_CHOICE, value: NO_CHOICE});
			operationTypeAC5.addItem({name: 'equals', value: HistoryLog.String_op_equals});
			operationTypeAC5.addItem({name: 'does not equals', value: HistoryLog.String_op_notEquals});
			operationTypeAC5.addItem({name: 'begins with', value: HistoryLog.String_op_beginWith});
			operationTypeAC5.addItem({name: 'does not begins with', value: HistoryLog.String_op_notBeginWith});


			operationUnitAC.addItem({name: 'days', value: HistoryLog.Date_unit_day});
			operationUnitAC.addItem({name: 'weeks', value: HistoryLog.Date_unit_week});
			operationUnitAC.addItem({name: 'months', value: HistoryLog.Date_unit_month});

			operationProtocolAC.addItem({name: 'Both', value: NO_CHOICE});
			operationProtocolAC.addItem({name: 'IPv4', value: 'IPv4'});
			operationProtocolAC.addItem({name: 'IPv6', value: 'IPv6'});

			operationActionAC.addItem({name: 'Abandoned', value: 'Abandoned'});
			operationActionAC.addItem({name: 'Bootp', value: 'Bootp'});
			operationActionAC.addItem({name: 'Declined', value: 'Declined'});
			operationActionAC.addItem({name: 'Expired', value: 'Expired'});
			operationActionAC.addItem({name: 'Fixed', value: 'Fixed'});
			operationActionAC.addItem({name: 'Freed', value: 'Freed'});
			operationActionAC.addItem({name: 'Issued', value: 'Issued'});
			operationActionAC.addItem({name: 'Offered', value: 'Offered'});
			operationActionAC.addItem({name: 'Renewed', value: 'Renewed'});
			operationActionAC.addItem({name: 'Reserved', value: 'Reserved'});
			operationActionAC.addItem({name: 'Unrecognized', value: 'Unrecognized'});

			sortAC.addItem({name: PLEASE_CHOICE, value: NO_CHOICE});
			sortAC.addItem({name: 'Lease Issue', value: 'endTime'});
			sortAC.addItem({name: 'Protocol', value: 'protocol'});
			sortAC.addItem({name: 'IP Address', value: 'ipAddress'});
			sortAC.addItem({name: 'MAC Address', value: 'macAddress'});
			sortAC.addItem({name: 'Host Name', value: 'hostName'});
			sortAC.addItem({name: 'Action', value: 'event'});
//			sortAC.addItem({name: 'Member Host Name', value: 'memberOrServer'});
		}

		// **********************************************************
		// Singleton attribute
		// **********************************************************

		private static var __AppModelLocator:AppModelLocator=null;

	}
}

// Declared outside package so it can be used 
// to prevent direct construction of AppModelLocator instances
class ConstructorBlock
{
}

